import qs from "webopenfather-qs";

// const baseURL = "http://qf.fsdy.learv.com/";
const baseURL = "/fsdy";

// export const request = (path: string, options: REQUEST.Options):Promise<????> => {
export const request = (path: string, options: REQUEST.Options) => {
  const { method = "GET", headers = {}, body = {}, params = {} } = options;
  return fetch(baseURL + path + "?" + qs.stringify(params), {
    method,
    headers: {
      "content-type": "application/x-www-form-urlencoded",
      ...headers,
    },
    body: Object.keys(body).length ? qs.stringify(body) : null,
  }).then((res) => res.json());
};
